cmake_minimum_required(VERSION 2.8)
project(jf_crowd_count)

add_compile_options(-std=c++11)
add_compile_options(-pthread)
#add_compile_options(-fPIC)

option(USE_GPU "Set to switch to build use GPU"  ON)
option(USE_ROS "use ros"  OFF)

find_package(OpenCV REQUIRED)

file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
file(GLOB_RECURSE HEADER_FILES include/*.h)

include_directories( 
	${OpenCV_INCLUDE_DIRS}
	/usr/local/include
    include
	3rdparty/include
)

if(USE_ROS)
	find_package(catkin REQUIRED COMPONENTS roscpp)
	catkin_package(
		INCLUDE_DIRS include
		LIBRARIES jf_crowd_count
	)
	include_directories(
		${catkin_INCLUDE_DIRS}
	)
endif()

if(USE_GPU)
	add_definitions(-DMXNET_USE_CUDA=1)
    link_directories(/usr/local/cuda/lib64)
    add_library(${PROJECT_NAME} SHARED
		${SOURCE_FILES}
		${HEADER_FILES}
	)
else()
	message("src_files ${SOURCE_FILES}")
	add_library(${PROJECT_NAME} SHARED
		${SOURCE_FILES}
		${HEADER_FILES}
	)
endif()

# 指定动态库版本
# VERSION 动态库版本
# SOVERSION API版本
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 0.0.0 SOVERSION 0)

target_link_libraries(${PROJECT_NAME}
    ${OpenCV_LIBRARIES}
    /usr/local/lib/libmxnet.so
)

if(USE_ROS)
else()
	install(TARGETS ${PROJECT_NAME}
        DESTINATION lib)
	install(DIRECTORY include/
        DESTINATION include)
endif()